<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of SalesforceEventMapper
 *
 * @author HP
 */
require_once(dirname(dirname(dirname(__FILE__)))."/General/InsightUser.php");
require_once(dirname(dirname(dirname(__FILE__)))."/POCO/SalesForceEventPoco.php");
class SalesforceEventMapper {
    private $insightUser;
    private static $arrFieldMap = array (
        "Id" => "Id",
        "Subject" => "Subject",
        "Location" => "Location",
        "IsAllDayEvent" => "IsAllDayEvent",
        "ActivityDateTime" => "ActivityDateTime",
        "ActivityDate" => "ActivityDate",
        "StartDateTime" => "StartDateTime",
        "EndDateTime" => "EndDateTime",
        "Description" => "Description",
        "OwnerId" => "OwnerId",
        "Type" => "Type",
        "IsPrivate" => "IsPrivate",
        "ShowAs" => "ShowAs",
        "IsDeleted" => "IsDeleted",
        "LastModifiedDate" => "LastModifiedDate",
        "IsRecurrence" => "IsRecurrence",
        "ReminderDateTime" => "ReminderDateTime",
        "IsReminderSet" => "IsReminderSet",
        "WhoId" => "WhoId"
    );
    
    public function __construct(InsightUser $insightUser) {
        $this->insightUser = $insightUser;
    }
    
    public function createModel(stdClass $record) {
        $eventModel = new SalesForceEventPoco();
        $eventModel->setId($record->Id);
        $eventModel->setSubject($record->fields->Subject);
        $eventModel->setLocation($record->fields->Location);
        $eventModel->setIsAllDayEvent($record->fields->IsAllDayEvent);
        $eventModel->setActivityDateTime($record->fields->ActivityDateTime);
        $eventModel->setActivityDate($record->fields->ActivityDate);
        $eventModel->setStartDateTime($record->fields->StartDateTime);
        $eventModel->setEndDateTime($record->fields->EndDateTime);
        $eventModel->setDescription($record->fields->Description);
        $eventModel->setOwnerId($record->fields->OwnerId);
        $eventModel->setType($record->fields->Type);
        $eventModel->setIsPrivate($record->fields->IsPrivate);
        $eventModel->setShowAs($record->fields->ShowAs);
        $eventModel->setIsDeleted($record->fields->IsDeleted);
        $eventModel->setLastModifiedDate($record->fields->LastModifiedDate);
        $eventModel->setIsRecurrence($record->fields->IsRecurrence);
        $eventModel->setReminderDateTime($record->fields->ReminderDateTime);
        $eventModel->setIsReminderSet($record->fields->IsReminderSet);
        $eventModel->setWhoId($record->fields->WhoId);
        
        if(isset($records->fields->EventAttendees)){
            foreach($records->fields->EventAttendees as $attendee) {
                
            }
        }
        
        return $eventModel;
    }
    
    public function createModelFromGoogleEvent(GoogleEvent $googleEvent) {
        $eventModel = new SalesforceEvent();
        $eventModel->setId($googleEvent->event_Id);
        $eventModel->setSubject($record->fields->Subject);
        $eventModel->setLocation($record->fields->Location);
        $eventModel->setIsAllDayEvent($record->fields->IsAllDayEvent);
        $eventModel->setActivityDateTime($record->fields->ActivityDateTime);
        $eventModel->setActivityDate($record->fields->ActivityDate);
        $eventModel->setStartDateTime($record->fields->StartDateTime);
        $eventModel->setEndDateTime($record->fields->EndDateTime);
        $eventModel->setDescription($record->fields->Description);
        $eventModel->setOwnerId($record->fields->OwnerId);
        $eventModel->setType($record->fields->Type);
        $eventModel->setIsPrivate($record->fields->IsPrivate);
        $eventModel->setShowAs($record->fields->ShowAs);
        $eventModel->setIsDeleted($record->fields->IsDeleted);
        $eventModel->setLastModifiedDate($record->fields->LastModifiedDate);
        $eventModel->setIsRecurrence($record->fields->IsRecurrence);
        $eventModel->setReminderDateTime($record->fields->ReminderDateTime);
        $eventModel->setIsReminderSet($record->fields->IsReminderSet);
        $eventModel->setWhoId($record->fields->WhoId);
    }
    
    public function createStdObject(SalesforceEvent $eventModel) {
        $record = new stdClass();
        $record->type = 'Event';
        $record->Id = $eventModel->getId();
        $record->fields["Subject"] = $eventModel->getSubject();
        $record->fields["Location"] = $eventModel->getLocation();
        $record->fields["IsAllDayEvent"] = $eventModel->getIsAllDayEvent();
        $record->fields["ActivityDateTime"] = $eventModel->getActivityDateTime();
        $record->fields["ActivityDate"] = $eventModel->getActivityDate();
        $record->fields["StartDateTime"] = $eventModel->getStartDateTime();
        $record->fields["EndDateTime"] = $eventModel->getEndDateTime();
        $record->fields["Description"] = $eventModel->getDescription();
        $record->fields["OwnerId"] = $eventModel->getOwnerId();
        $record->fields["Type"] = $eventModel->getType();
        $record->fields["IsPrivate"] = $eventModel->getIsPrivate();
        $record->fields["ShowAs"] = $eventModel->getShowAs();
        $record->fields["IsDeleted"] = $eventModel->getIsDeleted();
        $record->fields["LastModifiedDate"] = $eventModel->getLastModifiedDate();
        $record->fields["IsRecurrence"] = $eventModel->getIsRecurrence();
        $record->fields["ReminderDateTime"] = $eventModel->getReminderDateTime();
        $record->fields["IsReminderSet"] = $eventModel->getIsReminderSet();
        $record->fields["WhoId"] = $eventModel->getWhoId();
        return $record;
    }
}

?>
